<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">

	</head>

	<body style="padding:0px;background-color: white">
		<div id="toolbar" class="receipts_toolbar_style"></div>
		<div>
			<form id="ff" method="post">
				<table id="basicInfo" cellpadding="5" class="displaytable" style="text-align: left;margin-left: 10%;width: 80%;margin-top: 35px;">
					<tr>
						<td width="20%">
							<h id="star">* </h>区域类型</td>
						<td width="30%">
							<input class="easyui-combobox" style="width:100%;" type="text" name="REGION_TYPE" id="input_REGION_TYPE" data-options="panelHeight:'100',required:true" />
						</td>
						<td width="20%">
							<h id="star">* </h>区域名称</td>
						<td width="30%">
							<input class="easyui-combobox" style="width:100%;" type="text" name="REGION_NAME" id="input_REGION_NAME" data-options="panelHeight:'100',required:true" />
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>摊位门牌号</td>
						<td>
							<input class="easyui-combobox" style="width: 100%;" name="HOUSE_NUMBER" id="input_HOUSE_NUMBER" data-options="required:true" />
						</td>
						<td>
							<h id="star">* </h>单位时间</td>
						<td>
							<input class="easyui-textbox" style="width: 100%" name="UNIT_TIME" id="input_UNIT_TIME" data-options="required:true" />
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>租金(单位:元)</td>
						<td>
							<input class="easyui-textbox" style="width: 100%;" name="UNIT_RENT" id="input_UNIT_RENT" data-options="required:true" />
						</td>
						<td>
							<h id="star">* </h>保证金(单位:元)</td>
						<td>
							<input class="easyui-textbox" style="width: 100%" name="UNIT_MARGIN" id="input_UNIT_MARGIN" data-options="required:true" />
						</td>
					</tr>
					<tr style="display: none;">
						<td>ID</td>
						<td>
							<input class="easyui-textbox" style="width: 100%;" type="text" name="ID" id="input_ID" data-options="required:true" />
						</td>
						<td>Boost_ID</td>
						<td>
							<input class="easyui-textbox" style="width: 100%;" type="text" name="BOOST_ID" id="input_BOOST_ID" data-options="required:true" />
						</td>
					</tr>
				</table>
				<div id="new_footer" style="margin-top: 60px;">

				</div>
			</form>
		</div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 40%;height: 450px;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
			<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
		<script type="text/javascript" src="../../../JS/BasicInfomation.js"></script>
		<script type="text/javascript" src="../../../JS/MarketShareFunction/DialogShareFunction.js"></script>
				<script type="text/javascript" src="../../../JS/MarketShareFunction/MarketShareFunction.js"></script>
	<script type="text/javascript">
		var currid = AddFlag;
		var id = getID();
		var currPage = 0; //当前的页数
		var MaxPage = 0;
		var MinPage = 1;
		var isVerify = 0;
//		var curr_region_type = "";
//		var curr_region_name = "";
		var AddDialog;
		$(document).ready(function(){
			if(id != AddFlag && id != undefined) {
				currid = id;
				loadRemote();
			}
		});

		getPageMaxAndMin();
		addDialogFooter($("#new_footer"));

		var detailData = [{
			"icon": "icon-undo",
			"func": "cls()",
			"functionname": "清空"
		}]
		var receipts_type = RECEIPT_FRONT_SYMBOL;
		receipts_type += RECEIPT_NEXT_SYMBOL;
		receipts_type += RECEIPT_ADD_SYMBOL;
		receipts_type += RECEIPT_SAVE_SYMBOL;
		receipts_type += RECEIPT_DELETE_SYMBOL;
		content = AddReceiptsToolBar(receipts_type, detailData);
		$("#toolbar").append(content);

		iniREGIONTYPE();//区域联力查询函数

		function getPageMaxAndMin() {
			var _url = RemoteLinkAddress + "/market/boostrent/getmaxminid.do";
			$.ajax({
				type: "get",
				url: _url,
				dataType: "json",
				success: function(result) {
					if(result != null) {
						MaxPage = result.MAXID;
						MinPage = result.MINID;
						currPage = result.MINID + 1;
					}
				},
				error: function(xhr, status, error) {
					$.messager.alert("错误", "请求失败!");
				}
			});
		}

		function newdata() { //新建
			currid = AddFlag;
			currPage = 0;
			resetData();
		}

		function frontpage() { //上一张
			if(currPage > MinPage) {
				var _url = RemoteLinkAddress + '/market/boostrent/pre.do?ID=' + currPage;
				getRemoteData(_url);
			} else {
				$.messager.alert("提示", "没有上张");
			}
		}

		function nextpage() { //下一张
			if(currPage < MaxPage) {
				var _url = RemoteLinkAddress + '/market/boostrent/next.do?ID=' + currPage;
				getRemoteData(_url);
			} else {
				$.messager.alert(" 提示", "没有下张");
			}
		}

		function save() { //保存
			if($("input[name='NAME']").val() == "" || $("input[name='BASECOST']").val() == "") {
				$.messager.alert("警告", "数据不完整！");
				return;
			}
			if(currid != AddFlag) {
				getUpdateData();
			} else {
				getSaveData();
			}
		}

		function deletedata() { //删除
			if(isVerify === "1") {
				$.messager.alert("提示", "该单据已审核，不能删除！");
				return;
			}
			$.messager.confirm('Confirm', '是否删除', function(r) {
				if(r) {
					$.post(RemoteLinkAddress + "/market/boostrent/delete.do", {
							ID: currid
						},
						function(result) {
							if(result.msg == "success") {
								$.messager.alert({ // show success message
									title: '成功',
									msg: '删除成功'
								});
								nextpage();
							} else {
								$.messager.alert({ // show error message
									title: 'Error',
									msg: result.msg
								});
							}
						},
						'json');
				}
			});
		}

		function print() { //打印
			var pLocation = "HouseRepairManagementPrint.html?id=" + currPage;
			window.open(pLocation); /*打开pLocation中的链接html文档*/
		}

		function loadRemote() { //载入数据
			var _url = RemoteLinkAddress + '/market/boostrent/findbyid.do?ID=' + currid;
			getRemoteData(_url);
		}

		function getRemoteData(_url) {
			$.ajax({
				type: "get",
				url: _url,
				dataType: "json",
				success: function(result) {
					if(result != null) {
						isVerify = result.ISVERIFY;
						verifyStatus_Market(isVerify, true);
						currPage = result.ID;
						getFormData(result);
						getDialogFooterData(result);
					}
				},
				error: function(xhr, status, error) {
					$.messager.alert("错误", "请求失败!");
				}
			});
		}

		function cls() {
			$('#ff').form('reset');
		}

		function getSaveData() {
			var data = submitFormData();
			submitData(data);
		}

		function getUpdateData() {
			var data = submitFormData();
			submitData(data);
		}

		function submitData(_data) {
			var _url = "";
			if(currid == AddFlag) {
				_url = RemoteLinkAddress + "/market/boostrent/save.do";
			} else {
				_url = RemoteLinkAddress + "/market/boostrent/update.do";
			}
			$.ajax({
				dataType: 'JSON',
				url: _url,
				data: _data,
				type: "POST",
				success: function(result) {
					var parentLocation;
					parentLocation = searchParent("BoothChargeRatioList.html");
					parentLocation.dialogClose();
					$.messager.alert("提示信息", "保存成功");
				},
				error: function(result) {
					$.messager.alert("错误信息", "保存失败");
				}
			});
		}
	</script>

</html>